enum ChatSessionType {
  private, // 单聊
  group, // 群聊
}

class ChatSessionModel {
  final String id;
  final String name; // 聊天名称（群聊时为群名，单聊时可为空）
  final ChatSessionType type; // 会话类型：单聊/群聊
  final List<int> memberIds; // 会话成员ID列表
  final String? avatar; // 会话头像（群聊时为群头像，单聊时为对方头像）

  ChatSessionModel({
    required this.id,
    required this.name,
    required this.type,
    required this.memberIds,
    this.avatar,
  });

  factory ChatSessionModel.fromJson(Map<String, dynamic> json) =>
      ChatSessionModel(
        id: json['id'],
        name: json['name'],
        type: ChatSessionType.values.byName(json['type']),
        memberIds: List<int>.from(json['memberIds']),
        avatar: json['avatar'],
      );

  Map<String, dynamic> toJson() => {
    'id': id,
    'name': name,
    'type': type.name,
    'memberIds': memberIds,
    'avatar': avatar,
  };
}
